<!DOCTYPE html>
<html lang="en">

	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<meta name="description" content="">
		<meta name="author" content="">
		<title>新建商品</title>
		<link rel="stylesheet" href="../../css/base.css" />
		<link rel="stylesheet" href="../../css/common.css" />
		<link href="../../sbadmin/bower_components/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
		<script src="../../sbadmin/bower_components/jquery/dist/jquery.min.js"></script>
		<script type="text/javascript" src="../../js/weditor/crypto.js"></script>
		<script type="text/javascript" src="../../js/weditor/hmac-min.js"></script>
		<script type="text/javascript" src="../../js/weditor/sha1.js"></script>
		<script type="text/javascript" src="../../js/weditor/base64.js"></script>
		<script type="text/javascript" src="../../js/weditor/plupload.full.min.js"></script>
		<script type="text/javascript" src="../../js/weditor/oo.js"></script>
		<script type="text/javascript" src="../../js/weditor/wangEditor.js"></script>
		<script src="https://gosspublic.alicdn.com/aliyun-oss-sdk-4.4.4.min.js"></script>
		<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
		<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
		<!--[if lt IE 9]>
	<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
	<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
	<![endif]-->
		<style>
			body {
				padding: 0 15px !important;
			}
			
			.fengmian {
				margin-right: 20px;
			}
			
			#isMainImg img {
				width: 305px;
				height: 305px;
				border-radius: 4px;
			}
			
			#mainUpload img {
				width: 305px;
				height: 305px;
				border-radius: 4px;
			}
			
			#goodsImg img {
				width: 296px;
				height: 188px;
				border-radius: 4px;
			}
			
			.adsFile {
				width: 160px;
				height: 30px;
				background: none;
			}
			
			.fm-select {
				width: 15px;
				height: 15px;
				background: none;
				vertical-align: middle;
			}
			
			.ad-form-itemtt {
				width: 140px;
			}
		</style>
	</head>

	<body style="background:#FFF;">
		<div class="comm-tt-font pr">
			出售商品 > 新建商品
		</div>
		<div class="ftype-box">
			商品所属分类:<label id="ftype" class="ml10"></label>
			<a href="stype.html">更换</a>
		</div>
		<div class="comm-mbbox none"></div>
		<div class="upload-showbox none clb">
			<div class="fl">
				<div class="uploadImgbox">
					<img id="xmTanImg" src="" class="namepic" />
				</div>
			</div>
			<div class="fl ml20">
				<div>
					<input type="file" class="file-style adsFile" id="uploadfiles" onchange="xmTanUploadImg(this)" />
					<input type="hidden" id="imghidden" value="" />
				</div>
				<div>
					<span class="vm">是否设置成封面：</span>
					<span class="vm"><input type="checkbox" class="fm-select mr5" id="yes" />是</span>
				</div>
				<div class="clb" style="margin-top: 262px;">
					<a href="javascript:void(0);" class="fl commqx-btn" id="adqxBtn">取消</a>
					<a href="javascript:void(0);" class="fl commqr-btn ml15" id="adCfbtn">确定</a>
				</div>
			</div>
		</div>
		<div class="shop-detail-box pr">
			<div class="wo-form-item clb mt20">
				<div class="ad-form-itemtt fl"><em>*</em>封面图：</div>
				<div class="fl pr" id="mainUpload"></div>
				<div class="ad-form-itemcc fl" id="isMainImg" style="width: 310px;">
					<img src="../../img/ismain.png">
				</div>
				<div class="fl" style="margin-top: 140px;">
					(建议尺寸640*640)
				</div>
			</div>
			<div class="wo-form-item clb mt20">
				<div class="ad-form-itemtt fl"><em>*</em>商品图片：</div>
				<div class="wod-form-itemcc3 fl">
					<div id="goodsImg" class="fl"></div>
					<div class="fl" id="goodsUpload">
						<img src="../../img/nomain.png">
					</div>
					<div class="fl ml30" style="margin-top: 80px;">
						(建议尺寸670*426)
					</div>
				</div>
			</div>
			<div class="addGoodsBox">
				<div class="agbTt">基本信息</div>
			</div>
			<div class="clb">
				<div class="wo-form-item fl mt20" style="width: 460px;">
					<div class="ad-form-itemtt fl mt5"><em>*</em>商品编号：</div>
					<div class="wod-form-itemcc fl" style="width: 300px;">
						<input type='text' class='edit-input' style="width: 250px;" id='goodsCode' />
					</div>
				</div>
				<div class="wo-form-item fl mt20" style="width: 460px;">
					<div class="ad-form-itemtt fl mt5"><em>*</em>拍摄次数(次)：</div>
					<div class="wod-form-itemcc fl" style="width: 300px;">
						<input type="text" class="edit-input" style="width: 250px;" id="takeNum" />
					</div>
				</div>
			</div>
			<div class="clb">
				<div class="wo-form-item fl mt20" style="width: 460px;">
					<div class="ad-form-itemtt fl mt5"><em>*</em>商品名：</div>
					<div class="wod-form-itemcc fl" style="width: 300px;">
						<input type="text" class="edit-input" style="width: 250px;" id="goodsName" />
					</div>
				</div>
				<div class="wo-form-item fl mt20" style="width: 460px;">
					<div class="ad-form-itemtt fl mt5"><em>*</em>有效期(天)：</div>
					<div class="wod-form-itemcc fl" style="width: 300px;">
						<input type="text" class="edit-input" id="timeLimit" style="width: 250px;" />
					</div>
				</div>
			</div>
			<div class="clb">
				<div class="wo-form-item fl mt20" style="width: 460px;">
					<div class="ad-form-itemtt fl mt5"><em>*</em>售价：</div>
					<div class="wod-form-itemcc fl" style="width: 300px;">
						<input type="text" class="edit-input" id="price" style="width: 250px;" />
					</div>
				</div>
				<div class="wo-form-item fl mt20" style="width: 460px;">
					<div class="ad-form-itemtt fl mt5"><em>*</em>出售使用门店组：</div>
					<div class="wod-form-itemcc fl" style="width: 300px;">
						<select class="eic-select" style="width: 250px;" id="shopZu"></select>
					</div>
				</div>
			</div>
			<div class="clb">
				<div class="wo-form-item fl mt20" style="width: 460px;">
					<div class="ad-form-itemtt fl mt5"><em>*</em>指导价：</div>
					<div class="wod-form-itemcc fl" style="width: 300px;">
						<input type="text" class="edit-input" style="width: 250px;" id="guidePrice" />
					</div>
				</div>
				<div class="wo-form-item fl mt20" style="width: 460px;">
					<div class="ad-form-itemtt fl mt5"><em>*</em>是否上架：</div>
					<div class="wod-form-itemcc fl" style="width: 300px;">
						<select class="eic-select" style="width: 250px;" id="sfSj">
							<option value="1">是</option>
							<option value="0">否</option>
						</select>
					</div>
				</div>
			</div>
			<div class="clb">
				<div class="wo-form-item clb mt20" style="width: 460px;">
					<div class="ad-form-itemtt fl mt5"><em>*</em>是否儿童：</div>
					<div class="wod-form-itemcc fl" style="width: 300px;">
						<select class="eic-select" style="width: 250px;" id="sfChild">
							<option value="1">是</option>
							<option value="0">否</option>
						</select>
					</div>
				</div>
			</div>
			<div class="addGoodsBox">
				<div class="agbTt">附加信息</div>
			</div>
			<div class="clb">
				<div class="wo-form-item fl mt20" style="width: 460px;">
					<div class="ad-form-itemtt fl mt5"><em>*</em>精修底片(张)：</div>
					<div class="wod-form-itemcc fl" style="width: 300px;">
						<input type="text" class="edit-input" style="width: 250px;" id="psCount" />
					</div>
				</div>
				<div class="wo-form-item fl mt20" style="width: 460px;">
					<div class="ad-form-itemtt fl mt5"><em>*</em>服装造型(套/次)：</div>
					<div class="wod-form-itemcc fl" style="width: 300px;">
						<input type="text" class="edit-input" style="width: 250px;" id="clothingCount" />
					</div>
				</div>
			</div>
			<div class="clb">
				<div class="wo-form-item fl mt20" style="width: 460px;">
					<div class="ad-form-itemtt fl mt5"><em>*</em>精品相册(本)：</div>
					<div class="wod-form-itemcc fl" style="width: 300px;">
						<input type="text" class="edit-input" style="width: 250px;" id="albumCount" />
					</div>
				</div>
				<div class="wo-form-item fl mt20" style="width: 460px;">
					<div class="ad-form-itemtt fl mt5"><em>&nbsp;</em>彩妆(次)：</div>
					<div class="wod-form-itemcc fl" style="width: 300px;">
						<input type="text" class="edit-input" style="width: 250px;" id="caiZ" />
					</div>
				</div>
			</div>
			<div class="clb">
				<div class="wo-form-item fl mt20" style="width: 460px;">
					<div class="ad-form-itemtt fl mt5"><em>&nbsp;</em>拍摄张数(张)：</div>
					<div class="wod-form-itemcc fl" style="width: 300px;">
						<input type="text" class="edit-input" style="width: 250px;" id="pageCount" />
					</div>
				</div>
				<div class="wo-form-item fl mt20" style="width: 460px;">
					<div class="ad-form-itemtt fl mt5"><em>&nbsp;</em>MV拍摄(个)：</div>
					<div class="wod-form-itemcc fl" style="width: 300px;">
						<input type="text" class="edit-input" style="width: 250px;" id="mvPai" />
					</div>
				</div>
			</div>
			<div class="clb">
				<div class="wo-form-item fl mt20" style="width: 460px;">
					<div class="ad-form-itemtt fl mt5"><em>&nbsp;</em>场景数量(次)：</div>
					<div class="wod-form-itemcc fl" style="width: 300px;">
						<input type="text" class="edit-input" style="width: 250px;" id="placeCount" />
					</div>
				</div>
				<div class="wo-form-item fl mt20" style="width: 460px;">
					<div class="ad-form-itemtt fl mt5"><em>&nbsp;</em>拍摄花絮(个)：</div>
					<div class="wod-form-itemcc fl" style="width: 300px;">
						<input type="text" class="edit-input" style="width: 250px;" id="psHua" />
					</div>
				</div>
			</div>
			<div class="clb">
				<div class="wo-form-item fl mt20" style="width: 460px;">
					<div class="ad-form-itemtt fl mt5"><em>&nbsp;</em>摄影师：</div>
					<div class="wod-form-itemcc fl" style="width: 300px;">
						<input type="text" class="edit-input" style="width: 250px;" id="camerman" />
					</div>
				</div>
				<div class="wo-form-item fl mt20" style="width: 460px;">
					<div class="ad-form-itemtt fl mt5"><em>&nbsp;</em>拍摄时长(小时/次)：</div>
					<div class="wod-form-itemcc fl" style="width: 300px;">
						<input type="text" class="edit-input" style="width: 250px;" id="psTime" />
					</div>
				</div>
			</div>
			<div class="clb">
				<div class="wo-form-item fl mt20" style="width: 460px;">
					<div class="ad-form-itemtt fl mt5"><em>&nbsp;</em>电子书(个)：</div>
					<div class="wod-form-itemcc fl" style="width: 300px;">
						<input type="text" class="edit-input" style="width: 250px;" id="dzBook" />
					</div>
				</div>
			</div>
			<div class="addGoodsBox">
				<div class="agbTt">图文详情</div>
			</div>
			<div class="wo-form-item clb mt20">
				<div class="ad-form-itemtt fl"><em>&nbsp;</em>特别说明：</div>
				<div class="wod-form-itemcc fl" style="width: 1000px;">
					<div id="editor2" style="background: #fff;"></div>
				</div>
			</div>
			<div class="wo-form-item clb mt20">
				<div class="ad-form-itemtt fl" id="spsss"><em>*</em>商品详情：</div>
				<div class="wod-form-itemcc2 fl" style="width: 1000px;">
					<div id="editor" style="background: #fff;"></div>
				</div>
			</div>
			<div class="wo-form-item clb mt20">
				<div class="ad-form-itemtt fl"><em>&nbsp;</em>温馨提示：</div>
				<div class="wod-form-itemcc fl" style="width: 1000px;">
					<div id="editor3" style="background: #fff;"></div>
				</div>
			</div>
			<div class="wo-form-item clb mt20">
				<div class="ad-form-itemtt fl"></div>
				<div class="wod-form-itemcc fl">
					<div class="clb mt20">
						<a href="list.html" class="fl commqx-btn">取消</a>
						<a href="javascript:void(0);" class="fl commqr-btn ml15" id="qrbtn">确定</a>
					</div>
				</div>
			</div>
		</div>

		<!-- jQuery -->

		<!-- Bootstrap Core JavaScript -->
		<script src="../../sbadmin/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
		<!-- Metis Menu Plugin JavaScript -->
		<script src="../../sbadmin/bower_components/metisMenu/dist/metisMenu.min.js"></script>
		<!-- DataTables JavaScript -->
		<script src="../../sbadmin/bower_components/datatables/media/js/jquery.dataTables.min.js"></script>
		<script src="../../sbadmin/bower_components/datatables-plugins/integration/bootstrap/3/dataTables.bootstrap.min.js"></script>
		<!-- Custom Theme JavaScript -->
		<script src="../../sbadmin/dist/js/sb-admin-2.js"></script>
		<script src="../../js/layer/layer.js"></script>
		<script type="text/javascript" src="../../js/common.js"></script>
		<!-- Page-Level Demo Scripts - Tables - Use for reference -->
	</body>
	<script>
		var files2;
		var imgUrl;
		var stime;
		var appServer = 'https://order.wz1996.wang/wzbg/media/sts';
		var bucket = 'wangzheng1996';
		var region = 'oss-cn-shanghai';
		var urllib = OSS.urllib;
		var Buffer = OSS.Buffer;
		var endPoint = "https://oss-cn-shanghai.aliyuncs.com";
		var OSS = OSS.Wrapper;
		var STS = OSS.STS;
		var applyTokenDo = function(func) {
			var url = appServer;
			return urllib.request(url, {
				method: 'GET',
				headers: {
					'token': localStorage.getItem("token")
				}
			}).then(function(result) {
				var creds = JSON.parse(result.data).data.credentials;
				//console.log(creds);
				var client = new OSS({
					region: region,
					accessKeyId: creds.accessKeyId,
					accessKeySecret: creds.accessKeySecret,
					stsToken: creds.securityToken,
					endpoint: endPoint,
					bucket: bucket
				});
				return func(client);
			});
		};
		var uploadFile = function(client) {
			var file = files2[0];
			//var key = document.getElementById('object-key-file').value.trim() || 'object';
			var key = "shop_particulars/" + getRandom() + "." + file.name.split(".")[1];
			//console.log(file.name + ' => ' + key);
			return client.multipartUpload(key, file, {
				//progress: progress
			}).then(function(res) {
				console.log('1111111111111111111');
				console.log(res);
				console.log(res.res.requestUrls[0]);
				stime = "1";
				res.res.requestUrls[0] = res.res.requestUrls[0].indexOf('?') == -1 ? res.res.requestUrls[0] : res.res.requestUrls[0].split("?")[0];
				imgUrl = res.res.requestUrls[0];
				console.log(imgUrl)
				console.log('上传成功,图片地址为' + res.res.requestUrls[0]);
				//return listFiles(client);
			});
		};
		var uploadFile2 = function(client) {
			var file = document.getElementById('uploadfiles').files[0];
			var key = "shop_particulars/" + getRandom() + "." + file.name.split(".")[1];
			return client.multipartUpload(key, file, {}).then(function(res) {
				res.res.requestUrls[0] = res.res.requestUrls[0].indexOf('?') == -1 ? res.res.requestUrls[0] : res.res.requestUrls[0].split("?")[0];
				$("#imghidden").val(res.res.requestUrls[0])
			});
		};
		var E = window.wangEditor;
		var editor = new E('#editor');
		editor.customConfig.customUpload = true;
		editor.customConfig.uploadImgShowBase64 = true;
		editor.customConfig.customUploadInit = uploadInit;
		editor.customConfig.customUploadImg = function(files, insert) {
			files2 = files;
			applyTokenDo(uploadFile);
			var timet = setInterval(function() {
				if(stime == "1") {
					editor.cmd.do('insertHtml', '<img src="' + imgUrl + '" style="max-width:100%;"/>')
					clearInterval(timet)
				}
			}, 500);
		}
		editor.customConfig.uploadImgMaxSize = 20 * 1024 * 1024; //设置图片大小为20M
		editor.customConfig.uploadImgTimeout = 1000000; //图片上传超时限制10s
		this.editor.customConfig.pasteTextHandle = function(content) {
			// content 即粘贴过来的内容（html 或 纯文本），可进行自定义处理然后返回
			if(content == '' && !content) return ''
			var str = content
			str = str.replace(/<xml>[\s\S]*?<\/xml>/ig, '')
			str = str.replace(/<style>[\s\S]*?<\/style>/ig, '')
			str = str.replace(/<\/?[^>]*>/g, '')
			str = str.replace(/[ | ]*\n/g, '\n')
			str = str.replace(/&nbsp;/ig, '')
			console.log('****', content)
			console.log('****', str)
			return str
		}
		editor.customConfig.menus = [
			'head', // 标题
			'bold', // 粗体
			'fontSize', // 字号
			'fontName', // 字体
			'italic', // 斜体
			'underline', // 下划线
			'strikeThrough', // 删除线
			'foreColor', // 文字颜色
			'backColor', // 背景颜色
			'link', // 插入链接
			'list', // 列表
			'justify', // 对齐方式
			'quote', // 引用
			'emoticon', // 表情
			'image', // 插入图片
			'table', // 表格
			'video', // 插入视频
			'code', // 插入代码
			'undo', // 撤销
			'redo' // 重复
		];
		editor.create();
	</script>
	<script type="text/javascript">
		var E1 = window.wangEditor;
		var editor2 = new E1('#editor2');
		this.editor2.customConfig.pasteTextHandle = function(content) {
			// content 即粘贴过来的内容（html 或 纯文本），可进行自定义处理然后返回
			if(content == '' && !content) return ''
			var str = content
			str = str.replace(/<xml>[\s\S]*?<\/xml>/ig, '')
			str = str.replace(/<style>[\s\S]*?<\/style>/ig, '')
			str = str.replace(/<\/?[^>]*>/g, '')
			str = str.replace(/[ | ]*\n/g, '\n')
			str = str.replace(/&nbsp;/ig, '')
			console.log('****', content)
			console.log('****', str)
			return str
		}
		editor2.customConfig.menus = [
			'head', // 标题
			'bold', // 粗体
			'fontSize', // 字号
			'fontName', // 字体
			'italic', // 斜体
			'underline', // 下划线
			'strikeThrough', // 删除线
			'foreColor', // 文字颜色
			'backColor', // 背景颜色
			'list', // 列表
			'justify', // 对齐方式
			'code', // 插入代码
			'undo', // 撤销
			'redo' // 重复
		];
		editor2.create();
	</script>
	<script type="text/javascript">
		var E2 = window.wangEditor;
		var editor3 = new E2('#editor3');
		this.editor3.customConfig.pasteTextHandle = function(content) {
			// content 即粘贴过来的内容（html 或 纯文本），可进行自定义处理然后返回
			if(content == '' && !content) return ''
			var str = content
			str = str.replace(/<xml>[\s\S]*?<\/xml>/ig, '')
			str = str.replace(/<style>[\s\S]*?<\/style>/ig, '')
			str = str.replace(/<\/?[^>]*>/g, '')
			str = str.replace(/[ | ]*\n/g, '\n')
			str = str.replace(/&nbsp;/ig, '')
			console.log('****', content)
			console.log('****', str)
			return str
		}
		editor3.customConfig.menus = [
			'head', // 标题
			'bold', // 粗体
			'fontSize', // 字号
			'fontName', // 字体
			'italic', // 斜体
			'underline', // 下划线
			'strikeThrough', // 删除线
			'foreColor', // 文字颜色
			'backColor', // 背景颜色
			'list', // 列表
			'justify', // 对齐方式
			'code', // 插入代码
			'undo', // 撤销
			'redo' // 重复
		];
		editor3.create();
	</script>
	<script>
		//会员卡照片
		var img = document.getElementById("xmTanImg");

		function xmTanUploadImg(obj) {
			$("#ttt").css("display", "none");
			var file = obj.files[0];
			var reader = new FileReader();
			//读取文件过程方法
			reader.onloadstart = function(e) {
				console.log("开始读取....");
			}
			reader.onprogress = function(e) {
				console.log("正在读取中....");
			}
			reader.onabort = function(e) {
				console.log("中断读取....");
			}
			reader.onerror = function(e) {
				console.log("读取异常....");
			}
			reader.onload = function(e) {
				console.log("成功读取....");
				img.src = e.target.result;
				// 保存会员照片
				//localStorage.setItem("memberPhone", img.src);
				var icinmguuii = document.getElementsByClassName("ic-inmguuii")[0];
				//icinmguuii.style.display = "block";
				//或者 img.src = this.result;  //e.target == this
			}
			reader.readAsDataURL(file);
			applyTokenDo(uploadFile2);
		}
	</script>
	<!--图片上传-->
	<script>
		$(function() {
			$("#isMainImg,#goodsUpload").click(function() {
				$(".comm-mbbox").show();
				$(".upload-showbox").show();
				$("#xmTanImg").attr("src", "");
				$("#imghidden").val("");
				$("#uploadfiles").val("");
				$("#yes").attr("checked", false);
			})
			$("#adqxBtn").click(function() {
				$(".comm-mbbox").hide();
				$(".upload-showbox").hide();
				$("#xmTanImg").attr("src", "");
				$("#imghidden").val("");
				$("#uploadfiles").val("");
				$("#yes").attr("checked", false);
			})
			$("#adCfbtn").click(function() {
				var xmTanImg = $("#imghidden").val();
				if(xmTanImg == "") {
					layar("未上传图片！");
				} else {
					var imgVal = $("#imghidden").val();
					console.log(imgVal);
					var checkVal = $("input[type='checkbox']").prop('checked');
					console.log(checkVal)
					$(".comm-mbbox").hide();
					$(".upload-showbox").hide();
					if(checkVal == true) {
						var html = "<div class='fengmian pr'><span class='delSpan'>删除</span><img ismain='1' src='" + imgVal + "'></div>";
						$("#mainUpload").html(html);
					} else {
						var html = "<div class='sale-detailimg2 pr'><span class='delSpan'>删除</span><img ismain='0' src='" + imgVal + "'></div>"
						$("#goodsImg").append(html);
					}
				}
			})
			//删除图片
			$("#mainUpload").on("click", ".delSpan", function() {
				$(this).parent(".fengmian").remove();
			})
			//删除图片
			$("#goodsImg").on("click", ".delSpan", function() {
				$(this).parent(".sale-detailimg2").remove();
			})
		})
	</script>
	<script>
		var typeId = localStorage.getItem("typeId");
		var typeName = localStorage.getItem("typeName")
		$("#ftype").html(typeName);
		//获取门店组
		$.ajax({
			url: "https://order.wz1996.wang/wzbg/storegroup/available",
			type: 'get',
			contentType: 'application/json',
			beforeSend: function(request) {
				request.setRequestHeader("token", localStorage.getItem("token"));
			},
			success: function(data) {
				console.log(data);
				//登录状态
				var html = "";
				if(data.code == "1") {
					html += "<option value=''>请选择</option>";
					for(var i = 0; i < data.data.length; i++) {
						html += "<option value=" + data.data[i].storeGroup.id + ">" + data.data[i].storeGroup.name + "</option>";
					}
					$("#shopZu").html(html);
				} else if(data.code == "-1") {
					layar(data.msg);
					setTimeout("window.parent.frames.location.href='/xcxadmin/login.html'", 1000)
				} else {
					layar(data.msg);
				}
			},
			error: function(e) {
				errcode(e);
			}
		});
		//商品图片，先写死

		var result = [];
		$("#qrbtn").click(function() {
			$(".sale-detailimg2").eq(0).children("img").attr("ismain", "2");
			//封面图+商品图
			result = [];
			$(".sale-detailimg2").each(function() {
				console.log($(this).children("img").attr('ismain'))
				var single = {
					isMain: $(this).children("img").attr('ismain'),
					url: $(this).children("img").attr('src')
				};
				result.push(single)
			})
			var single2 = {
				isMain: $(".fengmian").children("img").attr('ismain'),
				url: $(".fengmian").children("img").attr('src')
			}
			result.push(single2);
			var goodsName = $("#goodsName").val(); //商品名称
			var goodsPrice = $("#price").val(); //商品价格
			var guidePrice = $("#guidePrice").val(); //指导价
			var goodsDetail = editor.txt.html().replace('<br>', ''); //商品详情
			var shopZu = $("#shopZu option:selected").val(); //出售使用门店租
			var goodsCode = $("#goodsCode").val(); //商品编码
			var takeNum = $("#takeNum").val(); //拍摄次数
			var pageCount = $("#pageCount").val(); //拍摄张数
			var psCount = $("#psCount").val(); //精修张数
			var clothingCount = $("#clothingCount").val(); //服装套数
			var placeCount = $("#placeCount").val(); //场景数量
			var albumCount = $("#albumCount").val(); //相册
			var camerman = $("#camerman").val(); //摄影师
			var timeLimit = $("#timeLimit").val(); //有效期
			var sfSj = $("#sfSj option:selected").val(); //是否上架
			var explain = editor2.txt.html().replace('<br>', ''); //特别说明
			var tip = editor3.txt.html().replace('<br>', ''); //温馨提示
			var sfChild = $("#sfChild option:selected").val(); //是否儿童
			var caiZ = $("#caiZ").val(); //彩妆
			var mvPai = $("#mvPai").val(); //mv拍摄
			var psHua = $("#psHua").val(); //拍摄花絮
			var psTime = $("#psTime").val(); //拍摄时长
			var dzBook = $("#dzBook").val(); //电子书
			//console.log($("#goodsImg"));
			if($("#mainUpload img").attr("isMain") == undefined) {
				layar("请上传封面图！");
			} else if($("#goodsImg img").attr("isMain") == undefined) {
				layar("请上传商品图！");
			} else if(goodsCode == "") {
				layar("请输入商品编号！");
			} else if(takeNum == "") {
				layar("请输入拍摄次数！");
			} else if(goodsName == "") {
				layar("请输入商品名称！");
			} else if(timeLimit == "") {
				layar("请输入有效期！");
			} else if(goodsPrice == "") {
				layar("请输入商品售价！");
			} else if(shopZu == "" || shopZu == null || shopZu == undefined) {
				layar("请选择门店组！");
			} else if(guidePrice == "") {
				layar("请输入指导价！");
			} else if(psCount == "") {
				layar("请输入精修底片！");
			} else if(clothingCount == "") {
				layar("请输入服装造型！");
			} else if(albumCount == "") {
				layar("请输入相册数量！");
			} else if(goodsDetail == "" || goodsDetail == null || goodsDetail == undefined) {
				layar("请输入商品详情！");
			} else {
				// 读取 html
				var post_data = {
					"media": result,
					"sku": {
						"albumCount": albumCount,
						"alias": "",
						"cameraman": camerman,
						"categoryId": typeId,
						"clothingCount": clothingCount,
						"code": goodsCode,
						"description": goodsDetail,
						"explain": explain,
						"guidePrice": guidePrice,
						"isKid": sfChild,
						"itemId": "",
						"name": goodsName,
						"onSaleTime": "",
						"pageCount": pageCount,
						"placeCount": placeCount,
						"properties": "",
						"psCount": psCount,
						"resume": "",
						"salePrice": goodsPrice,
						"status": sfSj,
						"stock": "",
						"takeTimes": takeNum,
						"timeLimit": timeLimit,
						"tip": tip,
						"isMakeUp": caiZ,
						"mvTakeTimes": mvPai,
						"takeInteresting": psHua,
						"takeDuration": psTime,
						"ebook": dzBook
					},
					"storeGroup": {
						"id": shopZu
					}
				}
				$.ajax({
					url: "https://order.wz1996.wang/wzbg/sku/add",
					type: 'post',
					contentType: 'application/json',
					data: JSON.stringify(post_data),
					beforeSend: function(request) {
						request.setRequestHeader("token", localStorage.getItem("token"));
					},
					success: function(data) {
						console.log(data);
						//登录状态
						if(data.code == "1") {
							layer.msg("添加成功！", {
								offset: '20%'
							});
							setTimeout("window.location.href='list.html'", 1000)
						} else if(data.code == "-1") {
							layar(data.msg);
							setTimeout("window.parent.frames.location.href='/xcxadmin/login.html'", 1000)
						}
					},
					error: function(e) {
						errcode(e);
					}
				});
			}

		})
	</script>

</html>